#!/bin/sh

mysql -uroot -p$OS_PASSWORD -e "DROP DATABASE vmstats;" || true
mysql -uroot -p$OS_PASSWORD -e "CREATE DATABASE vmstats;"
mysql -uroot -p$OS_PASSWORD -e "GRANT DELETE,INSERT,UPDATE,SELECT ON vmstats.* to openstack@'%' IDENTIFIED BY 'openstack';"
mysql -uroot -p$OS_PASSWORD -e "GRANT DELETE,INSERT,UPDATE,SELECT ON vmstats.* to openstack@'localhost' IDENTIFIED BY 'openstack';"
mysql -uroot -p$OS_PASSWORD vmstats -e "CREATE TABLE vmstats (vm CHAR(16), host CHAR(16), cpu TINYINT, time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, INDEX ixvm(vm), INDEX ixhost(host));"

